import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    islogin: false,
    userinfo: null,
    token: ""
  },

  mutations: {
    /** 登录成功 把用户信息存入state.userinfo */
    loginOK(state, userinfo){
      state.islogin = true;
      state.userinfo = userinfo;
      state.token = userinfo.userAuth.token;
    },

    /** 使当前登录用户失效，删除当前登录信息 */
    logout(state){
      islogin = false;
      state.userinfo = null;
    },

    /** 保存token */
    storeToken(state, token){
      state.token = token;
    }
  },

  actions: {
  },

  modules: {
  }

})
